package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.UserBean;
import com.project.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户端的用户表 前端控制器
 * </p>
 *
 * @author lhy
 * @since 2021-10-05
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户测试接口")
public class UserController extends ApiBaseController {
    @Autowired
    private IUserService userService;

    //@GetMapping("/findByItem/{pn}/{pageSize}/{userCode}/{realName}/{gentle}/{phone}")
    //public IPage<UserBean> findByItem(@PathVariable("pn") int pn,
    //                                  @PathVariable("pageSize") int pageSize,
    //                                  @PathVariable("userCode") String userCode,
    //                                  @PathVariable("realName") String realName,
    //                                  @PathVariable("gentle") String gentle,
    //                                  @PathVariable("phone") String phone){
    //    return userService.findByItem(pn,pageSize,userCode,realName,gentle,phone);
    //}

    @GetMapping("/findByItem")
    @ApiOperation(value = "按选项分页查询用户")
    public IPage<UserBean> findByItem(int pn,
                                      int pageSize,
                                      String userCode,
                                      String realName,
                                      String gentle,
                                      String phone) {
        return userService.findByItem(pn, pageSize, userCode, realName, gentle, phone);
    }

    @GetMapping("/registerUser")
    @ApiOperation(value = "注册用户")
    public String registerUser(String userCode, String realName, String phone, String gentle) {
        userService.registerUser(userCode, realName, phone, gentle);
        return "ok";
    }

}
